home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / pyshared / computerjanitor / missing_package_cruft_tests.py < prev    next >
Encoding:
Python Source  |  2009-04-27  |  2.0 KB  |  62 lines

  1. # missing_package_cruft_tests.py - unit tests for missing_package_cruft.py
  2. # Copyright (C) 2008, 2009  Canonical, Ltd.
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, version 3 of the License.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  15.  
  16.  
  17. import unittest
  18.  
  19. import computerjanitor
  20.  
  21.  
  22. class MockAptPackage(object):
  23.  
  24.     def __init__(self):
  25.         self.name = "name"
  26.         self.summary = "summary"
  27.         self.installedSize = 12765
  28.         self.installed = False
  29.         
  30.     def markInstall(self):
  31.         self.installed = True
  32.  
  33.  
  34. class MissingPackageCruftTests(unittest.TestCase):
  35.  
  36.     def setUp(self):
  37.         self.pkg = MockAptPackage()
  38.         self.cruft = computerjanitor.MissingPackageCruft(self.pkg)
  39.  
  40.     def testReturnsCorrectPrefix(self):
  41.         self.assertEqual(self.cruft.get_prefix(), "install-deb")
  42.  
  43.     def testReturnsCorrectPrefixDescription(self):
  44.         self.assert_("Install" in self.cruft.get_prefix_description())
  45.  
  46.     def testReturnsCorrectShortname(self):
  47.         self.assertEqual(self.cruft.get_shortname(), "name")
  48.  
  49.     def testReturnsCorrectName(self):
  50.         self.assertEqual(self.cruft.get_name(), "install-deb:name")
  51.  
  52.     def testReturnsCorrectDescription(self):
  53.         self.assert_("name" in self.cruft.get_description())
  54.  
  55.     def testSetsDescriptionWhenAsked(self):
  56.         pkg = computerjanitor.MissingPackageCruft(self.pkg, "foo")
  57.         self.assertEqual(pkg.get_description(), "foo")
  58.     
  59.     def testInstallsPackage(self):
  60.         self.cruft.cleanup()
  61.         self.assert_(self.pkg.installed)
  62.